package com.irdstudio.tdp.console.api.rest;

import java.util.List;

import com.irdstudio.sdk.beans.core.util.UUIDUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.irdstudio.tdp.console.service.facade.PaasAppsInfoService;
import com.irdstudio.tdp.console.service.vo.PaasAppsInfoVO;
import com.irdstudio.sdk.beans.core.vo.ResponseData;
import com.irdstudio.sdk.ssm.web.AbstractController;

@RestController
@RequestMapping("/api")
public class PaasAppsInfoController extends AbstractController  {
	
	@Autowired
	@Qualifier("paasAppsInfoServiceImpl")
	private PaasAppsInfoService paasAppsInfoService;

	
	/**
	 * 列表数据查询
	 * @param page
	 * @param size
	 * @return
	 */
	@RequestMapping(value="/paas/apps/infos", method=RequestMethod.POST)
	public @ResponseBody ResponseData<List<PaasAppsInfoVO>> queryPaasAppsInfoAll(
			PaasAppsInfoVO vo) {		
		List<PaasAppsInfoVO> outputVo = paasAppsInfoService.queryAllOwner(vo);
		return getResponseData(outputVo);
		
	}
	
	/**
	 * 根据主键查询详情
	 * @return
	 */
	@RequestMapping(value="/paas/apps/info/{appId}", method=RequestMethod.GET)
	public @ResponseBody ResponseData<PaasAppsInfoVO> queryByPk(@PathVariable("appId") String appId) {		
		PaasAppsInfoVO inVo = new PaasAppsInfoVO();
				inVo.setAppId(appId);
		PaasAppsInfoVO outputVo = paasAppsInfoService.queryByPk(inVo);
		return getResponseData(outputVo);
		
	}
	
	/**
	 * 根据主键删除信息
	 * @param paasAppsInfo
	 * @return
	 */
	@RequestMapping(value="/paas/apps/info", method=RequestMethod.DELETE)
	public @ResponseBody ResponseData<Integer> deleteByPk(@RequestBody PaasAppsInfoVO inPaasAppsInfoVo) {		
		int outputVo = paasAppsInfoService.deleteByPk(inPaasAppsInfoVo);
		return getResponseData(outputVo);
		
	}
	
	/**
	 * 根据主键更新信息
	 * @param inPaasAppsInfoVo
	 * @return
	 */
	@RequestMapping(value="/paas/apps/info", method=RequestMethod.PUT)
	public @ResponseBody ResponseData<Integer> updateByPk(@RequestBody PaasAppsInfoVO inPaasAppsInfoVo) {		
		int outputVo = paasAppsInfoService.updateByPk(inPaasAppsInfoVo);
		return getResponseData(outputVo);
		
	}
	
	/**
	 * 新增数据
	 * @param inPaasAppsInfoVo
	 * @return
	 */
	@RequestMapping(value="/paas/apps/info", method=RequestMethod.POST)
	public @ResponseBody ResponseData<String> insertPaasAppsInfo(@RequestBody PaasAppsInfoVO inPaasAppsInfoVo) {
		inPaasAppsInfoVo.setAppId(UUIDUtil.getUUID());
		int outputVo = paasAppsInfoService.insertPaasAppsInfo(inPaasAppsInfoVo);
		return getResponseData(inPaasAppsInfoVo.getAppId());
		
	}
}
